﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        double x1;
        double y1;
        double px1;
        double py1;
        double x2;
        double y2;
        double px2;
        double py2;
        int cx ;
        int cy ;
        int r1 = 0;
        int r2 = 50;
        double angle = 0;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            r1 = trackR1.Value;
            r2 = trackR2.Value;
            System.Drawing.Graphics graf = panel1.CreateGraphics();
            System.Drawing.Pen pen = new Pen(Color.White, 1);
            graf.Clear(Color.Black);
            timer1.Enabled = true;
            cx = panel1.Width / 2;
            cy = cx;
            x1 = cx + r1 * Math.Sin(angle);
            y1 = cy + r1 * Math.Cos(angle);
            px1 = x1;
            py1 = y1;
            x2 = x1 + r2 * Math.Sin(-angle*trackAngSp.Value/10);
            y2 = y1 + r2 * Math.Cos(-angle*trackAngSp.Value / 10);
            px2 = x2;
            py2 = y2;
        }

        
        private void timer1_Tick(object sender, EventArgs e)
        {
            angle = angle + 0.05;
            x1 = cx + r1 * Math.Sin(angle);
            y1 = cy + r1 * Math.Cos(angle);
            x2 = x1 + r2 * Math.Sin(-angle * trackAngSp.Value / 10);
            y2 = y1 + r2 * Math.Cos(-angle * trackAngSp.Value / 10);
            System.Drawing.Graphics graf = panel1.CreateGraphics();
            System.Drawing.Pen pen = new Pen(Color.Red, 1);
            if (checkRed.Checked)  
            graf.DrawLine(pen, Convert.ToInt16(px1), Convert.ToInt16(py1), Convert.ToInt16(x1), Convert.ToInt16(y1));
            pen.Color = Color.White;
            graf.DrawLine(pen, Convert.ToInt16(px2), Convert.ToInt16(py2), Convert.ToInt16(x2), Convert.ToInt16(y2));
            px1 = x1;
            py1 = y1; 
            px2 = x2;
            py2 = y2;
            r1 = trackR1.Value;
            r2 = trackR2.Value;
            timer1.Interval = trackSpeed.Value;

        }

        
    }
}
